package com.example.weight.greenSeasons.compost;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.RadioButton;
import android.widget.RadioGroup;

import com.example.weight.R;
import com.example.weight.greenSeasons.SolidLiquid.chuzha7_2;
import com.example.weight.greenSeasons.SolidLiquid.chuzha7_2Jiancharen;
import com.example.weight.greenSeasons.SolidLiquid.ribaoyang7_5;
import com.example.weight.greenSeasons.SolidLiquid.shebeijiancha7_4;
import com.example.weight.greenSeasons.SolidLiquid.shebeijiancha7_4jiancharen;
import com.example.weight.greenSeasons.SolidLiquid.shebeiyunxing7_1;
import com.example.weight.greenSeasons.SolidLiquid.shebeiyunxing7_1jiancharen;
import com.example.weight.greenSeasons.SolidLiquid.yuebaoyangNav;
import com.example.weight.greenSeasons.SolidLiquid.zhoubaoyang;
import com.example.weight.greenSeasons.flocculation.xuningribaoyang;
import com.example.weight.greenSeasons.flocculation.xuningshebeijiancha;
import com.example.weight.greenSeasons.flocculation.xuningshebeijianchaChecker;
import com.example.weight.greenSeasons.flocculation.xuningyuebaoyang_nav;
import com.example.weight.greenSeasons.waterDeal.EquipmentCheckNavTable;
import com.example.weight.greenSeasons.waterDeal.EquipmentCheckTable;
import com.example.weight.greenSeasons.waterDeal.EquipmentMonthlyMaintainNavTable;
import com.example.weight.greenSeasons.waterDeal.EquipmentRunningTable;
import com.example.weight.greenSeasons.waterDeal.EquipmentRunningTableCheck;
import com.example.weight.householdWaste.HouseholdWasteMaintainNavActivity;
import com.hjq.bar.OnTitleBarListener;
import com.hjq.bar.TitleBar;

public class CompostRoleSelectActivity extends AppCompatActivity {

    private String path, factory;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_chose_role);

        Intent previousIntent = getIntent();
        String name = previousIntent.getStringExtra("name");
        path = previousIntent.getStringExtra("path");
        factory = previousIntent.getStringExtra("factory");

        TitleBar titleBar = findViewById(R.id.role_select_titleBar);
        titleBar.setOnTitleBarListener(new OnTitleBarListener() {
            @Override
            public void onLeftClick(View v) { finish(); }

            @Override
            public void onTitleClick(View v) {}

            @Override
            public void onRightClick(View v) {}
        });

        RadioGroup radioGroup = findViewById(R.id.role_select_group);
        radioGroup.setOnCheckedChangeListener((group, checkedId) -> {
            RadioButton button = findViewById(checkedId);
            String role = button.getText().toString();

            switch (path) {
                case "daily": {
                    Intent intent;
                    if (role.equals("操作人")) {
                        intent = new Intent(this, CompostDailyMaintenanceActivity.class);
                    } else {
                        intent = new Intent(this, CompostDailyInspectorActivity.class);
                    }
                    intent.putExtra("name", name);
                    intent.putExtra("factory",factory);
                    startActivity(intent);
                    break;
                }
                case "daily_old": {
                    Intent intent;
                    if (role.equals("操作人")) {
                        intent = new Intent(this, CompostDailyMaintenanceActivity_old.class);
                    } else {
                        intent = new Intent(this, CompostDailyInspectorActivity_old.class);
                    }
                    intent.putExtra("name", name);
                    intent.putExtra("factory",factory);
                    startActivity(intent);
                    break;
                }
                case "week": {
                    Intent intent;
                    if (role.equals("操作人")) {
                        intent = new Intent(this, CompostWeekMaintenanceActivity.class);
                    } else {
                        intent = new Intent(this, CompostWeekInspectorActivity.class);
                    }
                    intent.putExtra("name", name);
                    intent.putExtra("factory",factory);
                    startActivity(intent);
                    break;
                }
                case "month": {
                    Intent intent;
                    intent = new Intent(this, DuifeiMonthMaintanenceNavActivity.class);
                    intent.putExtra("name", name);
                    intent.putExtra("role", role);
                    intent.putExtra("factory",factory);
                    startActivity(intent);
                    break;
                }
            }
        });
    }
}